﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace HumanResourceWeb.Models
{
    /// <summary>
    /// 
    /// </summary>
    public class Party
    {
        /// <summary>
        /// 
        /// </summary>
        public List<Employee> employees = new List<Employee>();

        /// <summary>
        /// コンストラクタ
        /// </summary>
        public Party()
        {
        }

        /// <summary>
        /// OID
        /// </summary>
        public long Id { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 社員情報を取得
        /// </summary>
        /// <param name="name">社員名称</param>
        /// <returns>Employee</returns>
        public Employee GetEmployee(string name)
        {
            // 本来はDBより取得するべきであるが、仮に実装する
            var imitation = from substance in this.employees
                           where substance.Name == name
                           select substance;
            return imitation.Count() == 0 ? new Employee() : imitation.First();
        }
    }
}
